$(document).ready(function()
{
	var form=$('#Form_Magazine_Index');
	var button_submit=$('#Magazine_Index_Submit');
	var button_reset=$('#Magazine_Index_Reset');
	
	var companyName=$('#Magazine_Index_CompanyName');
	var linkman=$('#Magazine_Index_Linkman');
	var phoneNumber=$('#Magazine_Index_PhoneNumber');
	var email=$('#Magazine_Index_Email');
	var postcode=$('#Magazine_Index_Postcode');
	var address=$('#Magazine_Index_Address');
	
	var ac=$('#AlertContainer');
	
	button_reset.click(function()
	{
		form.get(0).reset();
		return false;
	});
	
	form.submit(function()
	{
		if(companyName.val()=='')
		{
			companyName.focus();
			return false;
		}
	
		if(linkman.val()=='')
		{
			linkman.focus();
			return false;
		}
		
		if(phoneNumber.val()=='')
		{
			phoneNumber.focus();
			return false;
		}
		
		if(email.val()=='')
		{
			email.focus();
			return false;
		}
	
		if(postcode.val()=='')
		{
			postcode.focus();
			return false;
		}
	
		if(address.val()=='')
		{
			address.focus();
			return false;
		}
		
		var formData=
		{
			'CompanyName':companyName.val(),
			'Linkman':linkman.val(),
			'PhoneNumber':phoneNumber.val(),
			'Email':email.val(),
			'Postcode':postcode.val(),
			'Address':address.val()
		};		
		
		$.post(form.attr('action'),formData,function($data)
		{
			if($data=='Success')
			{
				ac.html('订阅成功');
				ac.fadeIn();
				form.get(0).reset();
			}
			else
			{
				//document.write($data);
				ac.html('服务器繁忙,请稍候在试..');
				ac.fadeIn();			
			}
		});
		
		return false;						 
	});
});